package com.test.mapper;

import com.test.mapper.UserMapperPlus;
import com.test.entity.User;
import com.test.util.MyBatisPlusUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Before;
import org.junit.Test;
import java.util.List;
public class UserMapperPlusTest {

    private SqlSession sqlSession;
    private UserMapperPlus userMapperPlus;

    @Before
    public void setup(){
        //获取SqlSession和Mapper
        sqlSession = MyBatisPlusUtil.getSqlSession();
        userMapperPlus = sqlSession.getMapper(UserMapperPlus.class);
        System.out.println("开始执行MyBatis CRUD测试...");
    }

    @Test
    public void queryList(){
        List<User> users = userMapperPlus.selectList(null);
        users.forEach(user -> {
            System.out.println(user);
        });
    }
    @Test
    public void update(){
        User user = new User("王五",15,"111@qq.com");
        userMapperPlus.updateById(user);
    }
}